import { storeToRefs } from 'pinia'
import { useDialogEvents } from '@/stores/dialogEvents.js'

import { Point } from '@/Utils/Point.js'
import { useMapStore } from '@/stores/map.js'
import { Zondy_docLayer } from '@/views/Home/Map/Hooks/initMap'
const { map } = storeToRefs(useMapStore())
const { addEventPosition } = storeToRefs(useDialogEvents())

export const addEventAttr = (addEvent) => {
  let position = addEventPosition.value
  var service = {
    name: 'guanggu',
    layerId: 2
  }

  // 处理事件发生时间信息
  var time = addEvent.time.replaceAll('-', '.').replaceAll('T', ' ')
  var docLayer = Zondy_docLayer
  var attr = [
    { type: 'number', key: '处理状态', value: Number(addEvent.status) },
    { type: 'string', key: '事件编号', value: String(addEvent.event) },
    { type: 'string', key: '事件类型', value: String(addEvent.type) },
    { type: 'number', key: '事件等级', value: Number(addEvent.grade) },
    { type: 'string', key: '发生时间', value: String(time) },
    { type: 'string', key: '发生地点', value: String(addEvent.address) },
    { type: 'string', key: '车牌号', value: String(addEvent.carNumber) },
    { type: 'string', key: '驾驶员', value: String(addEvent.carOwner) }
  ]
  var color
  switch (attr[0].value) {
    case 0:
      color = 6 //待处理---红色
      break
    case 1:
      color = 4 //处理中---黄色
      break
    case 2:
      color = 90 //已归档---绿色
      break
  }
  Point.add({ attr, color, docLayer, service, position })
}
